lexer grammar ValLexer;

@header{
package org.concepts.java.antlr.validator;
}

SPECIALCHARACTERS : ('.'|'_')+ ;

ALPHANUMERIC : ('a'..'z'|'A'..'Z'|'0'..'9')+ ;

EQUAL     : '=';
QUOTE     : ';';
DOLLAR    : '$';
LPAREN    : '(';
RPAREN    : ')';
COMMA     : ',';

STRING: '"' ~('"')* '"' ;

/*
 * Math operators
 */

PLUS      : '+';
MINUS     : '-';
MULTIPLY  : '*';
DIVIDE    : '/';
GT        : '>';
LT        : '<';
GTE       : '>=';
LTE       : '<=';
EQ        : '==';
NEQ       : '!=';

/*
 * Logical operators
 */
AND           :  '&&';
OR            :  '||';
NOT           :  '!';

/*
 * Whitespace is one or more space (' ') and/or tab ('\t') character. Tokens are
 * passed to the parser components on channels. In this case, we have decided
 * to pass all whitespace on a hidden channel that is not automatically
 * inspected by the parser.
 */
WHITESPACE: (' ' | '\t')+ {$channel = HIDDEN;};

/*
 * Newline is '\n' on most operating systems. In some operating system it's
 * '\r' following by '\n'. 
 */
NEWLINE: ('\r'? '\n')+ {$channel = HIDDEN;};

/*
 * Single comment is a line that starts with '//' and ends with a new line.
 * It can consist of zero or more characters, execpt any new line character.
 * By using 'skip();' java code we have instructed the lexer to not process 
 * this token. Thus this token won't be available to the parser. 
 */
SINGLE_COMMENT : '//' ~('\r' | '\n')* NEWLINE {skip();};


/*
 * Multi line comment start with '\/*' and ends with '*\/'. It can consist of
 * any characted in the middle. By default matching of a token is greedy, i.e.
 * the lexer will go till the last '*\/' in the characted stream. We want the
 * lexer to stop at the first '*\/', thus we specify greedy to false in the
 * token option.
 */
MULTI_COMMENT options { greedy = false; } : '/*' .* '*/' NEWLINE? {skip();};
